<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<div class="middle padtop10 myclear">
	<div class="page-content">
		
		<!-- bread crumb -->
		<p id="bread-crumb">
			<a href="<?php echo base_url();?>">
				<?php echo $lang['home']?>
			</a>
			<?php echo $lang['monitor']?>
		</p>
		<!-- end bread crumb -->
		<h3>
			<?php echo $lang['campaign_bad']?>
		</h3>
		<br style="clear:both;" />
        <table cellpadding="3" cellspacing="1">
			<tr>
				<td>
					<b class="ver-middle marright5"><?php echo $lang['group']?>: </b>
					<select id="slGroup" class="ver-middle">
                    	<option value="-1" <?php echo ($gid == -1 ? 'selected="selected"' : '');?>>
							<?php echo $lang['all']?>
                        </option>
						<option value="0" <?php echo ($gid == 0 ? 'selected="selected"' : '');?>>
							<?php echo $lang['enduser']?>
                        </option>
						<?php foreach ($lstGroup as $item){?>
						<option value="<?php echo $item['groupid']?>" <?php echo ($item['groupid'] == $gid ? 'selected="selected"' : '');?>>
							<?php echo $item['groupname']?>
                        </option>
						<?php }?>
					</select>
				</td>
				<td style="padding-left:15px">
					<b class="ver-middle marright5"><?php echo $lang['date']?>: </b>
					<input type="text" id="slDate" size="30" value="<?php echo $fromdate.' / '.$todate;?>" />
				</td>
				<td style="padding-left:15px">
					<input type="button" value="<?php echo $lang['apply'];?>" onclick="filterChange();" />
				</td>
			</tr>
		</table><br />
		<table class="tbl-list" width="100%" border="1">
			<tr>
				<td width="3%" class="td-label" style="text-align:center">
					<b>#</b>
				</td>
                <td class="td-label" width="6%">
					<b><?php echo $lang['date'];?></b>
				</td>
				<td class="td-label" width="8%">
					<b><?php echo $lang['user'];?></b>
				</td>
				<td width="15%" class="td-label">
					<b><?php echo $lang['campaign'];?></b>
				</td>
				<td class="td-label" style="width:10%">
					<b><?php echo $lang['from_date'].'<br />'.$lang['to_date'];?></b>
				</td>
				<td class="td-label" width="11%">
					<b><?php echo $lang['budget'];?> (click)</b>
				</td>
				<td class="td-label" style="text-align:right" width="9%">
					<b><?php echo $lang['total_click'];?></b>
				</td>
                <td class="td-label" style="text-align:right" width="9%">
					<b><?php echo $lang['realclick'];?></b>
				</td>
                <td class="td-label" style="text-align:right" width="9%">
					<b><?php echo $lang['view'];?></b>
				</td>
                <td class="td-label" style="text-align:right" width="9%">
					<b><?php echo $lang['ctr'];?></b>
				</td>
                <td class="td-label" style="text-align:right">
					<b><?php echo $lang['percent'];?> (%)</b>
				</td>
			</tr>
			<?php $i = 0; foreach ($items as $item){ $i++; ?>
			<tr class="row">
				<td style="text-align:center">
					<?php echo $i;?>
				</td>
                <td style="text-align:center">
					<?php echo date('d/m/Y', strtotime($item->date));?>
				</td>
				<td>
					<?php echo $item->username;?>
                    <p style="color:#999;font-size:11px"><?php echo $item->groupname;?></p>
				</td>
				<td>
                	<a href="<?php echo site_url('campaigndetail/index/?campaignid='.$item->campaingid.'&fromdate='.$fromdate.'&todate='.$todate);?>" target="_blank">
						<?php echo $item->campaignname;?>
                    </a>
				</td>
				<td>
					<?php echo date('d/m/Y', strtotime($item->activate)).'<br />'.date('d/m/Y', strtotime($item->expire));?>
				</td>
				<td>
					<?php echo number_format($item->budget);?>
                    <p style="color:#999"><?php echo $item->typebudget == 0 ? $lang['to_campaign'] : $lang['to_day'];?></p>
				</td>
				<td style="text-align:right;">
					<?php echo number_format($item->click);?>
				</td>
                <td style="text-align:right;">
					<?php echo number_format($item->realclick);?>
				</td>
                <td style="text-align:right;">
					<?php echo number_format($item->view);?>
				</td>
                <td style="text-align:right;">
					<?php echo $item->ctr;?>
				</td>
                <td style="text-align:right;">
					<?php echo number_format($item->percent,2);?>
				</td>
			</tr>
			<?php }?>
		</table>
        <!-- paging -->
        <div class="myclear martop20">
            <div class="brv-paging-left">
                <table class="tbl-list brv-paging" border="1">
                    <tr>
                        <td class="brv-paging-name">
                            <?php echo $lang['page'].' '. $page.' ['.$pages.']'?>
                        </td>
                        
                        <td class="brv-paging-pre-next">
                            <img class="brv-img-pre" alt="previous" src="/images/imgpre.gif" onclick="goPage(<?php echo $page > 1 ? $page - 1 : $page;?>)" />
                            <img class="brv-img-next" alt="next" src="/images/imgnext.gif" onclick="goPage(<?php echo $page < $pages ? $page + 1 : $page;?>)" />
                        </td>
                    </tr>
                </table>
            </div>
            <!-- important. fix for ie 6. Don't remove -->
            <!--[if IE 6]><br class="clearboth" /><![endif]-->
        </div>
        <!-- end paging -->
	</div>
</div><br />
<script type="text/javascript">
$(document).ready(function(){
	$('.tbl-list .row').mouseover(function(){
		$(this).css('background','#ffc');
	});
	$('.tbl-list .row').mouseout(function(){
		$(this).css('background','none');
	});
});
$('#slDate').DatePicker({
	format:'Y-m-d',
	date: ['<?php echo $fromdate;?>', '<?php echo $todate;?>'],
	current: '<?php echo date('Y-m-d');?>',
	calendars: 2,
	mode: 'range',
	starts: 1,
	position: 'bottom',
	onChange: function(formated, dates){
		$('#slDate').val(formated);
		$('#slDate').val(formated.join(' / '));
		$('#slDate').DatePickerHide();
	}
});
function goPage(strVal)
{
	var groupid = $('#slGroup').val();
	var ftdate = $('#slDate').val().split(' / ');
	window.location.href = '<?php echo site_url('monitor/campaignBad');?>/?gid=' + groupid + '&fd=' + ftdate[0] + '&td=' + ftdate[1] + '&page=' + strVal;
}
function filterChange()
{
	var groupid = $('#slGroup').val();
	var ftdate = $('#slDate').val().split(' / ');
	window.location.href = '<?php echo site_url('monitor/campaignBad');?>/?gid=' + groupid + '&fd=' + ftdate[0] + '&td=' + ftdate[1];
}
</script>